<?php

use yii\helpers\Html;
use metronic\widgets\ActiveForm;
$this->registerJsFile('/js/book-select2.js', ['depends' => 'metronic\assets\Select2Asset']);
?>
<div class="app-tag-book-form">

    <?php $form = ActiveForm::begin() ?>

    <?php if ($model->isNewRecord): ?>
        <?= Html::activeHiddenInput($model, 'tag_id', ['value' => Yii::$app->request->get('tag_id')]) ?>
        <?= $form->field($model, 'book_id')->select2($model->book_id ? [$model->book_id => $model->book->name . '_' . $model->book->author] : [], ['class' => 'book'])->wrapper(['width' => 7]) ?>
    <?php else: ?>
        <?= $form->field($model, 'book_id')->textInput(['value' => $model->book->name . '_' . $model->book->author, 'disabled' => true])->wrapper(['width' => 7]) ?>
    <?php endif ?>

    <?= $form->field($model, 'display_order')->numberInput()->hint('0 ~ 255之间，值越大，显示越靠前')->wrapper(['width' => 3]) ?>

    <?php ActiveForm::end() ?>

</div>
